package wuxianshua.config;

import com.alibaba.druid.pool.DruidDataSource;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.stereotype.Repository;

import javax.sql.DataSource;
import java.io.IOException;

//@Configuration
//@MapperScan(basePackages={"wuxianshua.dao"})
//@ComponentScan(basePackages ={ "wuxianshua"})
//@Repository
public class MybatisConf {

//    @Bean
//    public   DataSource dataSource(){
//        DruidDataSource dataSource = new DruidDataSource();
//        dataSource.setDriverClassName("com.mysql.jdbc.Driver");
//        dataSource.setPassword("root");
//        dataSource.setUsername("root");
//        dataSource.setUrl("jdbc:mysql://localhost:3306/testmysql?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8");
//        return  dataSource;
//    }
//
////    @Bean
//    public SqlSessionFactoryBean sqlsessionFactoryBean() throws IOException {
//        SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
//        sqlSessionFactoryBean.setDataSource( dataSource());
//        sqlSessionFactoryBean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath*:mapper/*.xml"));
////        sqlSessionFactoryBean.setConfigLocation();
//        return  sqlSessionFactoryBean;
//    }

}